#ifndef __DS1338_H__
#define __DS1338_H__


/*
 * ioctl cmd
 */
#define DS1338_IOC_MAGIC		'd'

#define DS1338_RTC_WRITE_TIME		_IOWR(DS1338_IOC_MAGIC, 1, ds_rtc_time)
#define DS1338_RTC_GET_TIME			_IOWR(DS1338_IOC_MAGIC, 2,ds_rtc_time)

#define DS1338_RTC_READ_ALL_REG		_IOWR(DS1338_IOC_MAGIC, 3,ds_rtc_time)
#define DS1338_RTC_READ_SINGLE_REG	_IOWR(DS1338_IOC_MAGIC, 4, unsigned int)
#define DS1338_RTC_READ_TIME		_IOWR(DS1338_IOC_MAGIC, 5,ds_rtc_time)
#define DS1338_RTC_WRITE_SINGLE_REG	_IOWR(DS1338_IOC_MAGIC, 6, write_reg_value)

#define CONTROL_REG		0x07
#define YEAR	0x06
#define MONTH	0x05
#define DATE	0x04
#define HOUR	0x02
#define MINUTE	0x01
#define SECOND	0x00

#define _RTC_TIME_
#ifdef _RTC_TIME_
typedef struct _ds1338_rtc_time
{
	unsigned char year;
	unsigned char month;
	unsigned char day;
	unsigned char hour;
	unsigned char minute;
	unsigned char second;
	//unsigned int weekday;
}ds_rtc_time;
#else
typedef struct
{
	unsigned long year : 6;	    /* 2000 - 2063 */
	unsigned long month : 4;    /* 1 - 12 */
	unsigned long day : 5;     /* 1 - 31 */
	unsigned long hour : 5;	    /* 0 - 23 */
	unsigned long minute : 6;   /* 0 - 59 */
	unsigned long second : 6;   /* 0 - 59 */
}ds_rtc_time;
#endif

typedef struct _write_reg_value
{
	unsigned char reg;
	unsigned char value;
}write_reg_value;

#endif	/* __DS1338_H__ */


